package com.applet.dish.controller;

import com.applet.dish.service.DishService;
import com.applet.result.Result;
import com.applet.vo.DishVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 菜品管理 controller
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/user/dish")
public class DishController {

    @Resource
    private DishService dishService;



    /**
     * 菜品管理
     *        根据分类id 查询某个分类下所有菜品及菜品口味
     * @param categoryId
     */
    @GetMapping("/list")
    public Result<List<DishVO>> queryDishListAndFlavorByCategoryId(@NotNull(message = "分类id为空") Long categoryId){
        log.info("菜品管理 - 查询分类id: {}下所有菜品", categoryId);
        List<DishVO> dishVOList = dishService.queryDishListAndFlavorByCategoryId(categoryId);
        return Result.success(dishVOList);
    }



}
